import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ClientForm, ClientQuery, ClientVO } from './types';

/**
 * 查询客户端信息列表
 * @param query
 * @returns {*}
 */

export const listClient = (query?: ClientQuery): AxiosPromise<ClientVO[]> => {
  return request({
    url: '/iot/client/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询客户端信息详细
 * @param clientId
 */
export const getClient = (clientId: string | number): AxiosPromise<ClientVO> => {
  return request({
    url: '/iot/iot/client/' + clientId,
    method: 'get'
  });
};

/**
 * 新增客户端信息
 * @param data
 */
export const addClient = (data: ClientForm) => {
  return request({
    url: '/iot/client',
    method: 'post',
    data: data
  });
};

/**
 * 修改客户端信息
 * @param data
 */
export const updateClient = (data: ClientForm) => {
  return request({
    url: '/iot/client',
    method: 'put',
    data: data
  });
};

/**
 * 删除客户端信息
 * @param clientId
 */
export const delClient = (clientId: string | number | Array<string | number>) => {
  return request({
    url: '/iot/client/' + clientId,
    method: 'delete'
  });
};
